package com.sg.service.biz.pbff.nb;

import com.sg.common.util.RedisUtil;
import com.sg.dto.integration.framework.BizSceneDto;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ： 手工接入方法
 * @version 1.0
 * @since 2022/5/28 15:32
 */
@Service
public class NbRole {
    @Resource
    private RedisUtil redisClient;

    /**
     * code:batchClearUserInfoFromRedis
     * name:Redis批量清空用户信息
     * desc:undefined
     * gen by moon at 2022/7/4 下午6:46:59
     **/
    @Trace(operationName = "Redis批量清空用户信息")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public BatchClearUserInfoFromRedisRespDto batchClearUserInfoFromRedis(BatchClearUserInfoFromRedisReqDto reqDto) {
        BatchClearUserInfoFromRedisRespDto retData = new BatchClearUserInfoFromRedisRespDto();
        if (reqDto.getBeginMemberList() == null || reqDto.getBeginMemberList().isEmpty()) {
            return retData;
        }
        for (String member : reqDto.getBeginMemberList()) {
            redisClient.delete("userbase-" + member);
            redisClient.delete("inductionInfo-" + member);
        }
        return retData;
    }

    /**
     * code:collectionRemoveExistingData
     * name:D查询过滤后可推荐业务场景列表
     * desc:undefined
     * gen by moon at 10/28/2022, 8:28:09 PM
     **/
    @Trace(operationName = "D查询过滤后可推荐业务场景列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public QueryHostTypeCollectionRemoveExistingDataListRespDto queryHostTypeCollectionRemoveExistingDataList(QueryHostTypeCollectionRemoveExistingDataListReqDto reqDto) {
        QueryHostTypeCollectionRemoveExistingDataListRespDto retData = new QueryHostTypeCollectionRemoveExistingDataListRespDto();
        for (BizSceneDto oneScene : reqDto.getBizSceneList()) {
            if (!reqDto.getHostTypeBizScnList().contains(oneScene.getBizSceneId())) {
                retData.getBizSceneList().add(oneScene);
            }
        }
        return retData;
    }


    //手工接入方法
}
